﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataEquipmentSpotMaster" @search="()=>{getTableDataEquipmentSpotMaster();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EquipmentId_FormItem" prop="EquipmentId" :label="$t('message.autotrans._Model_EquipmentSpotMaster_Equipment')">
            <el-select v-model="searchDataEquipmentSpotMaster.EquipmentId" clearable>
               <el-option v-for="item in stateEquipmentSpotMaster.AllEquipments" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductId_FormItem" prop="ProductId" :label="$t('message.autotrans._Model_EquipmentSpotMaster_ProductId')">
            <el-input v-model="searchDataEquipmentSpotMaster.ProductId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductCode_FormItem" prop="ProductCode" :label="$t('message.autotrans._Model_EquipmentSpotMaster_ProductCode')">
            <el-input v-model="searchDataEquipmentSpotMaster.ProductCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="MasterBarcode_FormItem" prop="MasterBarcode" :label="$t('message.autotrans._Model_EquipmentSpotMaster_MasterBarcode')">
            <el-input v-model="searchDataEquipmentSpotMaster.MasterBarcode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="SpotType_FormItem" prop="SpotType" :label="$t('message.autotrans._Model_EquipmentSpotMaster_SpotType')">
            <el-select v-model="searchDataEquipmentSpotMaster.SpotType" clearable>
               <el-option key="Appearance" value="Appearance" :label="$t('message.autotrans._Enum_SpotTypeEmum_Appearance')"></el-option>
               <el-option key="SafetyDevice" value="SafetyDevice" :label="$t('message.autotrans._Enum_SpotTypeEmum_SafetyDevice')"></el-option>
               <el-option key="DetectionInstrument" value="DetectionInstrument" :label="$t('message.autotrans._Enum_SpotTypeEmum_DetectionInstrument')"></el-option>
               <el-option key="NgMaster" value="NgMaster" :label="$t('message.autotrans._Enum_SpotTypeEmum_NgMaster')"></el-option>
               <el-option key="OkMaster" value="OkMaster" :label="$t('message.autotrans._Enum_SpotTypeEmum_OkMaster')"></el-option>
               <el-option key="ControlSystem" value="ControlSystem" :label="$t('message.autotrans._Enum_SpotTypeEmum_ControlSystem')"></el-option>
               <el-option key="CoolSystem" value="CoolSystem" :label="$t('message.autotrans._Enum_SpotTypeEmum_CoolSystem')"></el-option>
               <el-option key="MaintenanceStatus" value="MaintenanceStatus" :label="$t('message.autotrans._Enum_SpotTypeEmum_MaintenanceStatus')"></el-option>
               <el-option key="MaintenanceRecords" value="MaintenanceRecords" :label="$t('message.autotrans._Enum_SpotTypeEmum_MaintenanceRecords')"></el-option>
               <el-option key="LeakageProtection" value="LeakageProtection" :label="$t('message.autotrans._Enum_SpotTypeEmum_LeakageProtection')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OpId_FormItem" prop="OpId" :label="$t('message.autotrans._Model_EquipmentSpotMaster_OpId')">
            <el-input v-model="searchDataEquipmentSpotMaster.OpId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OpCode_FormItem" prop="OpCode" :label="$t('message.autotrans._Model_EquipmentSpotMaster_OpCode')">
            <el-input v-model="searchDataEquipmentSpotMaster.OpCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Active_FormItem" prop="Active" :label="$t('message.autotrans._Model_EquipmentSpotMaster_Active')">
            <el-select v-model="searchDataEquipmentSpotMaster.Active" clearable>
               <el-option :key="1" :value=true :label="$t('message._system.common.vm.tips_bool_true')"></el-option>
               <el-option :key="0" :value=false :label="$t('message._system.common.vm.tips_bool_false')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateTime_FormItem" prop="CreateTime" :label="$t('message.autotrans._Model_EquipmentSpotMaster_CreateTime')">
            <el-date-picker v-model="searchDataEquipmentSpotMaster.CreateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateTime_FormItem" prop="UpdateTime" :label="$t('message.autotrans._Model_EquipmentSpotMaster_UpdateTime')">
            <el-date-picker v-model="searchDataEquipmentSpotMaster.UpdateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateBy_FormItem" prop="CreateBy" :label="$t('message.autotrans._Model_EquipmentSpotMaster_CreateBy')">
            <el-input v-model="searchDataEquipmentSpotMaster.CreateBy" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateBy_FormItem" prop="UpdateBy" :label="$t('message.autotrans._Model_EquipmentSpotMaster_UpdateBy')">
            <el-input v-model="searchDataEquipmentSpotMaster.UpdateBy" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/EquipmentManagement/EquipmentSpotMaster/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/EquipmentSpotMaster/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/EquipmentSpotMaster/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/EquipmentSpotMaster/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/EquipmentSpotMaster/EquipmentSpotMasterExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefEquipmentSpotMaster" v-bind="tableDataEquipmentSpotMaster">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/EquipmentManagement/EquipmentSpotMaster/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/EquipmentManagement/EquipmentSpotMaster/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/EquipmentManagement/EquipmentSpotMaster/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageEquipmentManagementEquipmentSpotMasterIndex;true;Digitalmes.EquipmentManagement.Controllers;EquipmentSpotMaster">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { equipmentspotmasterApi } from '/@/api/equipmentmanagement/equipmentspotmaster';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateEquipmentSpotMaster = reactive({
    
    AllEquipments: [] as any[],
});

const searchDataEquipmentSpotMaster = ref({
        EquipmentId: null,
        ProductId: null,
        ProductCode: '',
        MasterBarcode: '',
        SpotType: undefined,
        OpId: null,
        OpCode: '',
        Active: undefined,
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
});

// 定义变量内容
const tableRefEquipmentSpotMaster = ref();
const tableDataEquipmentSpotMaster = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page关联设备'),key: 'EquipmentSpotMaster_Equipment',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page所属产线'),key: 'EquipmentSpotMaster_ProductId',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans.Page所属产线编号'),key: 'EquipmentSpotMaster_ProductCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page标件条码'),key: 'EquipmentSpotMaster_MasterBarcode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page标件类型'),key: 'EquipmentSpotMaster_SpotType',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page所属工位'),key: 'EquipmentSpotMaster_OpCode',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans.Page所属工位编号'),key: 'EquipmentSpotMaster_OpCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page激活'),key: 'EquipmentSpotMaster_Active',type: 'switch',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateTime'),key: 'EquipmentSpotMaster_CreateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateTime'),key: 'EquipmentSpotMaster_UpdateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateBy'),key: 'EquipmentSpotMaster_CreateBy',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateBy'),key: 'EquipmentSpotMaster_UpdateBy',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans._AdminIsValid'),key: 'EquipmentSpotMaster_IsValid',type: 'switch',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataEquipmentSpotMaster = () => {
    tableRefEquipmentSpotMaster.value.doSearch(equipmentspotmasterApi().search, searchDataEquipmentSpotMaster.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataEquipmentSpotMaster)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataEquipmentSpotMaster)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataEquipmentSpotMaster)
};

// 删除
const onDelete = (row: any) => {
    equipmentspotmasterApi().delete([row.ID]).then(() => { getTableDataEquipmentSpotMaster()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefEquipmentSpotMaster.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      equipmentspotmasterApi().delete(selectedids).then(() => { getTableDataEquipmentSpotMaster()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefEquipmentSpotMaster.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataEquipmentSpotMaster)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataEquipmentSpotMaster)
};

const onExport = () => {
	const selected = tableRefEquipmentSpotMaster.value.getSelectedRows();
	if (selected.length > 0) {
		equipmentspotmasterApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		equipmentspotmasterApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/EquipmentManagement/EquipmentSpotMaster/GetEquipments',[],false).then(x=>{stateEquipmentSpotMaster.AllEquipments = x});
        getTableDataEquipmentSpotMaster();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

